﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SedCup.Code.Model;

namespace SedCup.Code.View.Components
{
    public partial class FieldTask : Field
    {
        private Task localTask;
        /// <summary>
        /// Az ezen a mezőn található feladat
        /// </summary>
        public Task LocalTask
        {
            get { return localTask; }
            set { localTask = value; this.UpdateTask(); }
        }


        public FieldTask(int id, Task task) : base(id)
        {
            InitializeComponent();

            this.LocalTask = task;
        }

        /// <summary>
        /// A task adatainak megjelenítése
        /// </summary>
        private void UpdateTask()
        {
            this.panelTop.Controls.Clear();

            PanelTask task = new PanelTask();

            task.TimeLeft = this.LocalTask.remaining;
            task.FullTime = this.LocalTask.duration;
            task.Price = this.LocalTask.profit;
            task.Penalty = this.LocalTask.penalty;

            if (this.LocalTask.type == "c++")
                task.ProgLang = PanelTask.Language.CPP;
            else if (this.LocalTask.type == "c#")
                task.ProgLang = PanelTask.Language.CSHARP;
            else
                task.ProgLang = PanelTask.Language.JAVA;

            if (this.LocalTask.status == "free")
                task.TaskState = PanelTask.State.TODO;
            else if (this.LocalTask.status == "working")
                task.TaskState = PanelTask.State.INPROGRESS;
            else
                task.TaskState = PanelTask.State.DONE;

            task.Dock = DockStyle.Fill;
            this.panelTop.Controls.Add(task);
        }
    }
}
